package com.base.Queue;

import com.alibaba.fastjson.JSONObject;
import com.base.helper.WebHelper;
import lombok.extern.log4j.Log4j;

import java.util.concurrent.TimeUnit;

@Log4j
public class SbdCallBackWorker2 implements Runnable {
    private String URL; //回调的CallBack
    private JSONObject jsonObject;
    private int time;

    public SbdCallBackWorker2(String URL, JSONObject jsonObject) {
        this.URL = URL;
        this.jsonObject = jsonObject;
        this.time =3;
    }

    public SbdCallBackWorker2(String URL, JSONObject jsonObject, int time){
        this.URL = URL;
        this.jsonObject = jsonObject;
        this.time =time;
    }
    @Override
    public void run() {
        String result= WebHelper.doBodyPostFJ(URL, jsonObject);
        if (result == null && time>0){
            time --;
            SbdCallBackWorker2 worker=new SbdCallBackWorker2(URL,jsonObject,time);
            DelayOrderQueueManager manager = DelayOrderQueueManager.getInstance();
            manager.put(worker, 3, TimeUnit.MILLISECONDS);
        }
        log.warn("[话单通知]"+URL+":"+result);
    }
}
